import Vue from 'vue'
import Vuex from 'vuex'
import persisted from 'vuex-persistedstate'

Vue.use(Vuex)
Vue.use(persisted)

export default new Vuex.Store({
  state: {
    backcolor: 'rgb(243, 119, 119)',
    maskstate: false,
    list: [],
    todoarrow: false,
    donearrow: false,
    celarrow: false,
  },
  mutations: {
    changemask(state, val) {
      state.maskstate = val
    },
    changelist(state, obj) {
      if (obj.type == 'add') {
        state.list.unshift(obj.data)
        state.todoarrow = true
      }
    },
    changetodo(state, obj) {
      if (obj.type == 'init') {
        state.todoarrow = !state.todoarrow

      } else if (obj.type == 'todo') {
        state.todoarrow = true
      }

    },
    changedone(state, obj) {
      if (obj.type == 'init') {
        state.donearrow = !state.donearrow
      } else if (obj.type == 'done') {
        state.donearrow = true
      }

    },
    changecel(state, obj) {
      if (obj.type == 'init') {
        state.celarrow = !state.celarrow
      } else if (obj.type == 'cancel') {
        state.celarrow = true
      }

    },
    changecolor(state, val) {
      state.backcolor = val
    },
    
  },
  actions: {},
  modules: {},
  plugins: [persisted()]
})